import { ElTag } from 'element-plus'
import { h } from 'vue'
import { SelectItem } from './types'

export const statusSelect: SelectItem<any>[] = [
  { value: true, label: '正常', type: 'success' },
  { value: false, label: '停用', type: 'danger' }
]

export const hTag = (value: any, select: SelectItem<any>[]) => {
  const item = select.find(_ => _.value === value)
  return item && h(ElTag, { type: item.type }, {
    default: () => item.label
  })
}

export const hStatusTag = (value: any) => hTag(value, statusSelect)

export type MenuType = 'dir' | 'menu' | 'action'

export const menuTypeSelect: SelectItem<MenuType>[] = [
  { value: 'dir', label: '目录', type: 'primary' },
  { value: 'menu', label: '菜单', type: 'success' },
  { value: 'action', label: '动作', type: 'danger' }
]
